var os=navigator.platform.toLowerCase();
	var uant=navigator.userAgent.toLowerCase();
	if(uant.indexOf("android")<0&&os!="iphone"){
		location.href="news";
	}
$(function(){
	$(".firstNews").height($(".firstNews").width()/2);
	$(".fntop").height($(".firstNews").height()-$(".fnbottom").height());
});
function showNewsList(){
	getFirstNews();
	getNews();
	getNews2("jsqy");
	getNews2("hyyy");
	getNews2("fajs");
}
function getFirstNews(){
	$.ajax({
		url:"newsxwrd",
		type:"get",
		contentType:"application/json",
		dataType : 'json',
		data:{index:1,isFirst:1},
		success:function(msg){
			var article=msg.news;
			$(".firstNews").css("background-image","url('"+msg.imgpath+"/"+article.pic+"')");
			$(".fnbottom").html(article.item_title);
			$("#fisrtId").val(article.item_id)
		}
	});
}
function getNews(){
	var index=$("#xwrdindex").val();
	$.ajax({
		url:"newsxwrd",
		type:"get",
		contentType:"application/json",
		dataType : 'json',
		data:{index:index,isFirst:0},
		success:function(msg){
			var article=msg.news;
			if(msg.more==1){
				$("#xwrdmore").show();
				$("#xwrdindex").val(parseInt(index)+1);
				if(parseInt(index)>1){
					$("#xwrdup").show();
				}
			}else{
				if(parseInt(index)>1){
					$("#xwrdckgd").hide();
				}
			}
			var html="";
			for(var i=0;i<article.length;i++){
				if(i==3){
					break;
				}else{
					html+="<div class=\"newspre\">";
					html+="<div class=\"newsimage\" onclick=\"newsdetail("+article[i].item_id+")\">";
					html+="<img src=\""+msg.imgpath+"/"+article[i].pic+"\" style=\"width:100%;height:100%\"/></div>";
					html+="<div class=\"newsinfo\">";
					html+="<div class=\"newstitle\" onclick=\"newsdetail("+article[i].item_id+")\">"+article[i].item_title+"</div>";
					html+="<div class=\"newsover\" onclick=\"newsdetail("+article[i].item_id+")\">"+article[i].item_desc+"</div>";
					html+="<div class=\"newsover\">"+article[i].date+"</div>";
					html+="</div><div class=\"cleardiv\"></div></div><div class=\"cleardiv\"></div>";
				}
			}
			$("#xwrd").append(html);
		}
	});
}
function upxwrd(type){
	var index=$("#"+type).find(".newspre").length-1;
	for(var i=index;i>2;i--){
		$("#"+type).find(".newspre")[i].remove();
	}
	$("#"+type+"index").val("2");
	$("#"+type+"up").hide();
	$("#"+type+"ckgd").show();
	location.hash="#"+type;
	//getNews();
	
}
function getNews2(type){
	var index=$("#"+type+"index").val();
	$.ajax({
		url:"news"+type,
		type:"get",
		contentType:"application/json",
		dataType : 'json',
		data:{index:index},
		success:function(msg){
			var article=msg.news;
			if(msg.more==1){
				$("#"+type+"more").show();
				$("#"+type+"index").val(parseInt(index)+1);
				if(parseInt(index)>1){
					$("#"+type+"up").show();
				}
			}else{
				if(parseInt(index)>1){
					$("#"+type+"ckgd").hide();
				}
			}
			var html="";
			for(var i=0;i<article.length;i++){
				if(i==3){
					break;
				}else{
					html+="<div class=\"newspre\">";
					html+="<div class=\"newsimage\" onclick=\"newsdetail("+article[i].item_id+")\">";
					html+="<img src=\""+msg.imgpath+"/"+article[i].pic+"\" style=\"width:100%;height:100%\"/></div>";
					html+="<div class=\"newsinfo\">";
					html+="<div class=\"newstitle\" onclick=\"newsdetail("+article[i].item_id+")\">"+article[i].item_title+"</div>";
					html+="<div class=\"newsover\" onclick=\"newsdetail("+article[i].item_id+")\">"+article[i].item_desc+"</div>";
					html+="<div class=\"newsover\">"+article[i].date+"</div>";
					html+="</div><div class=\"cleardiv\"></div></div><div class=\"cleardiv\"></div>";
				}
			}
			$("#"+type).append(html);
		}
	});
}
function readNews(){
	var id=$("#fisrtId").val();
	newsdetail(id);
}
function newsdetail(id){
	window.open("news_detail_mobile?id="+id);
}